package com.wolfking.jeesite.freemarker.method;

import com.wolfking.jeesite.entity.User;
import com.wolfking.jeesite.freemarker.FreemarkerMethod;
import com.wolfking.jeesite.sso.SsoService;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@FreemarkerMethod("getCurrentLoginUser")
public class GetCurrentLoginUserMethod implements TemplateMethodModelEx {

    @Autowired
    private SsoService ssoService;

    @Override
    public Object exec(List list) throws TemplateModelException {
        User user = ssoService.getUser();
        user = user == null ? new User() : user;
        return user;
    }
}
